home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / bin / DXUtils / dxtex.txt < prev    next >
Text File  |  2001-10-11  |  9KB  |  177 lines

  1. Readme for the DirectX Texture Tool
  2.  
  3.  
  4. Purpose and Audience
  5. --------------------
  6. The purpose of this tool is to allow DirectX SDK users to easily create texture
  7. maps that use the DXTn compression formats.  Creating a DXTn-compressed
  8. texture is actually not that difficult to do: DirectDraw's Blt function can
  9. do the conversion for you.  Advanced developers will probably want to write
  10. their own tools that meet their specific needs.  But this tool provides useful
  11. basic functionality.
  12.  
  13.  
  14. DxTex Functionality
  15. -------------------
  16. Opens BMP and DDS files (See below for a description of the DDS file format)
  17. Opens BMP files as alpha channel, either explicitly or implicitly (via 
  18. foo_a.bmp naming)
  19. Saves textures in DDS format
  20. Supports conversion to all five DXTn compression formats
  21. Supports generation of mip maps (using a box filter)
  22. Supports visualization of alpha channel as a greyscale image or via a user-
  23. selectable background color
  24. Supports easy visual comparison of image quality between formats
  25.  
  26. Note: DxTex does not currently support textures with surface formats that
  27. do not contain at least an R, G, and B texture (such as D3DFMT_G16R16 and 
  28. D3DFMT_A8), although D3DX can load and save such textures in DDS format.
  29.  
  30.  
  31. User Interface
  32. --------------
  33. DxTex uses a pretty traditional user interface.  Each texture map is a 
  34. document, and several documents can be open at a time.  The one thing that
  35. is a bit unusual about the UI is that each document can hold the texture
  36. in either one or two formats at once while the document is open in DxTex.
  37. For instance, one could import a BMP file, which would automatically create
  38. a 32-bit ARGB texture.  One could then choose to convert the texture to 
  39. DXT1 format.  The document now remembers the image in *both* formats, and
  40. the user can flip between the formats by clicking in the window or by 
  41. choosing "Original" and "New" in the View menu.  This makes it easy for
  42. the user to observe any artifacts introduced by image compression, and to
  43. try several different compression formats without progressive degradation
  44. of the image  For instance, if this technique were not used and the user
  45. converted an image from ARGB to DXT1, all but one bit of alpha would be lost.
  46. If the user then decided to convert to DXT2, there would still be only two
  47. alpha levels.  With DxTex's system, the second conversion is done from the
  48. original ARGB format, and the DXT2 image will contain all 16 levels of alpha
  49. supported by DXT2.  When the image is saved, the "original" format is 
  50. discarded, and only the "new" format is stored.
  51.  
  52. There are a few consequences of this system that one must remember:
  53. - If no format conversion has been requested since the document was opened,
  54.   the one format is the "original" format and that is the format in which
  55.   the image will be written when the document is saved.
  56. - If format conversion has been requested since the document was opened, the
  57.   converted format is the "new" format and that is the format in which the
  58.   image will be written when the document is saved.
  59. - If a second format conversion is requested, the "new" format from the first
  60.   conversion is replaced with the second format.  The "original" format will
  61.   be unchanged.
  62. - Generating of mip maps applies to both formats simultaneously.
  63. - If the original format has multiple mip maps, and conversion to a new format
  64.   is requested, the new format will automatically have multiple mip maps as 
  65.   well.
  66. It's not as complicated as it sounds: with time, this two-format system 
  67. becomes natural and efficient to use.
  68.  
  69.  
  70. DxTex Performance
  71. -----------------
  72. DxTex uses the Direct3D Reference Rasterizer to draw the textures, 
  73. regardless of what 3D hardware is available.  So with larger textures 
  74. (greater than 256x256), the program may be somewhat slow, depending on your 
  75. CPU speed.
  76.  
  77.  
  78. DDS File Format
  79. ---------------
  80. DxTex's native file format is called "DDS" file format, because it 
  81. encapsulates the information in a DirectDrawSurface.  It has the following 
  82. format:
  83.  
  84.     DWORD dwMagic (0x20534444, or "DDS ")
  85.     DDSURFACEDESC2 ddsd (this provides information about the surface format)
  86.     BYTE bData1[] (this is the surface data for the main surface)
  87.     [BYTE bData2[]...] (surface data for attached surfaces, if any, follow)
  88.  
  89. This format is easy to read and write, and supports features such as alpha
  90. and multiple mip levels, as well as DXTn compression.  The "Compress" sample 
  91. application on the DirectX SDK demonstrates how to properly import a DDS file.
  92.  
  93. The user should note that it is not necessary to use the DDS format in order
  94. to use DXTn-compressed textures, or vice-versa.  But the two work well 
  95. together.
  96.  
  97.  
  98. Mip Maps
  99. --------
  100. Mip mapping is a technique that improves image quality and reduces texture
  101. memory bandwidth by providing prefiltered versions of the texture image at
  102. multiple resolutions.
  103.  
  104. To generate mip maps in DxTex, the width and height of the source image must 
  105. both be powers of 2.  Choose "Generate Mip Maps" from the Format menu.  
  106. Filtering is done via a simple box filter, i.e., the four nearest pixels are
  107. averaged to produce each destination pixel.  More sophisticated filtering can
  108. be found in other image processing programs.
  109.  
  110.  
  111. Alpha
  112. -----
  113. Many texture formats include an alpha channel, which provides opacity 
  114. information at each pixel.  DxTex fully supports alpha in textures.  When
  115. importing a BMP file, if a file exists of the same size with "_a" at the end
  116. (e.g., foo.bmp and foo_a.bmp), the second file will be loaded as an alpha
  117. channel.  The blue channel of the second BMP is stored in the alpha channel.
  118. Once a document is open, the user can explicitly load a BMP file as the alpha 
  119. channel via the "Open As Alpha Channel" command on the File menu.
  120.  
  121. To view the alpha channel directly without the RGB channels, choose "Alpha
  122. Channel Only" from the View menu.  The alpha channel will appear as a 
  123. greyscale image.  Note that if no alpha channel has been loaded, the alpha
  124. channel will be 100% everywhere and the image will appear solid white when
  125. viewing "Alpha Channel Only".  To turn off "Alpha Channel Only", just choose
  126. that menu item a second time.
  127.  
  128. In the usual view, the effect of the alpha channel is visible because the 
  129. window has a solid background color which shows through the texture where the
  130. alpha channel is less than 100%.  The user can change this background color
  131. by choosing "Change Background Color" from the View menu.  This choice does
  132. not affect the texture itself or the data that is written when the file is
  133. saved.
  134.  
  135. The DXT2 and DXT4 formats use premultiplied alpha, which means that the
  136. red, green, and blue values stored in the surface are already multiplied
  137. by the corresponding alpha value.  DirectDraw cannot blit from a surface
  138. containing premultiplied alpha to one containing non-premultiplied alpha,
  139. so some DxTex operations (Open as Alpha Channel, conversion to DXT3, and
  140. conversion to DXT5) are not possible on DXT2 and DXT4 formats.  Supporting
  141. textures using these formats is difficult on Direct3D devices which do
  142. not support DXTn textures, because DirectDraw cannot handle blitting them
  143. to a traditional ARGB surface either (unless that ARGB surface uses 
  144. premultiplied alpha as well, which is rare).  So you may find it easier to
  145. use DXT3 rather than DXT2 and DXT5 rather than DXT4 when possible.
  146.  
  147.  
  148. Command-Line Options
  149. --------------------
  150. Command-line options can be used to pass input files, an output file name, and
  151. processing options to DxTex.  If an output file name is specified, the program
  152. exits automatically after writing the output file, and no user interface is 
  153. presented.
  154.  
  155. dxtex [infilename] [-a alphaname] [-m] [DXT1|DXT2|DXT3|DXT4|DXT5] [outfilename]
  156.  
  157. infilename:               The name of the file to load.  This can be a BMP or 
  158.                           DDS file.
  159.  
  160. -a alphaname:             If "-a" is specified, the next parameter is the name
  161.                           of a BMP file to load as the alpha channel.  Note:
  162.                           if no alpha filename is specified, DxTex will still
  163.                           look for a file named infilename_a.bmp and, if it 
  164.                           exists, use that as the alpha channel.
  165.  
  166. -m:                       If this option is specified, mipmaps are generated.
  167.  
  168. DXT1|DXT2|DXT3|DXT4|DXT5: Specifies compression format.  If no format is 
  169.                           specified, the image will be in ARGB-8888.
  170.  
  171. outfilename:              Specifies the name of the destination file.  If this
  172.                           is not specified, the user interface will show the 
  173.                           current file and all requested operations.  If an 
  174.                           outfilename is specified, the app will exit after 
  175.                           saving the processed file without presenting a user 
  176.                           interface.
  177.